<?php
/**
 * QQAS - share your knowledge to the world!
 *
 * @author		xiaochong0302 <xiaochong0302@gmail.com>
 * @copyright	Copyright (c) 2011, Koogua Studio.
 * @license		http://www.qqas.org/user_guide/license.html
 * @link		http://www.qqas.org
 * @since		Version 1.0
 * @filesource
 */


class ModeratorModel extends Model
{

	//缓存版主
	public function cacheModerators()
	{
	    $results = $moderators = array();
        $field = array('user_id','username','category_id');
    	$order = array('display_order' => 'asc');
    	$results = $this->field($field)->order($order)->select();

    	if (!empty($results))
    	{
    		foreach ($results as $value)
    		{
    			$moderators[$value['category_id']][$value['user_id']] = $value;
    		}
    	}
    	F('cache_moderators', $moderators);
	}
	
	
	/**
	 * //删除版主记录
	 *
	 * @param int $userID
	 * @return null
	 */
	public function deleteModerator($userID)
	{
		$this->where('user_id='.$userID)->delete();
		$this->cacheModerators();
	}

}

/* End of file ModeratorModel.class.php */
/* Location: ./App/Lib/Model/ModeratorModel.class.php */
